package com.zy.bean.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zy.bean.vo.FlowChartVo;
import com.zy.util.VersionUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 流程图记录表
 *
 * @TableName api_flow_chart_records
 */
@TableName(value = "api_flow_chart_records")
@Data
public class ChartRecords implements Serializable {
    /**
     *
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 流程图编号
     */
    @TableField(value = "code")
    private String code;

    /**
     * 流程名称
     */
    @TableField(value = "name")
    private String name;

    /**
     * 流程描述
     */
    @TableField(value = "describe")
    private String describe;

    /**
     * 0 未激活
     * 1 激活
     */
    @TableField(value = "is_active")
    private Integer isActive;

    /**
     *
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     *
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 项目编号
     */
    @TableField(value = "project_code")
    private String projectCode;

    /**
     * 版本编号
     */
    @TableField(value = "active_version_code")
    private String activeVersionCode;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public static FlowChartVo tranceBoToVo(ChartRecords chartRecords, VersionUtil versionUtil) {
        FlowChartVo flowChartVo = new FlowChartVo();
        flowChartVo.setCode(chartRecords.getCode());
        flowChartVo.setName(chartRecords.getName());
        flowChartVo.setDescribe(chartRecords.getDescribe());
        flowChartVo.setIsActive(chartRecords.getIsActive());
        flowChartVo.setCreateTime(chartRecords.getCreateTime());
        flowChartVo.setUpdateTime(chartRecords.getUpdateTime());
        flowChartVo.setProjectCode(chartRecords.getProjectCode());
        flowChartVo.setActiveVersionInfo(versionUtil.getVersionByCode(chartRecords.getActiveVersionCode()));
        flowChartVo.setVersionList(versionUtil.getVersionListByProjectCode(chartRecords.getCode()));
        return flowChartVo;
    }
}
